/**
 * Contains main class for testing
 */
package logic;

import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import logic.pathelements.Cable;
import logic.pathelements.Firewall;
import logic.pathelements.Hub;
import logic.pathelements.PC;
import logic.pathelements.PathElement;
import logic.pathelements.Protocol;
import logic.pathelements.Router;
import logic.pathelements.Switch;

/**
 *
 * @author
 */
public class OldNetworkModelTest {

    public static void createNetwork(Network network) {
        try {
            //First PC
            network.addPathElement(new PC(0, "MAC", 2));
            network.setActivePathElmentNetworkInterfaceIp(0, 0, "192.168.1.1");
            network.setActivePathElmentNetworkInterfaceIp(0, 1, "192.168.1.6");
            //first PC - first hub cable
            network.addPathElement(new Cable(1, 5, 5));
            network.connect(1, 0, 0, 0);
            //First hub
            network.addPathElement(new Hub(2, 2, 6, 6));
            network.connect(2, 0, 1, 1);
            //first hub - first switch cable
            network.addPathElement(new Cable(3, 5, 5));
            network.connect(3, 0, 2, 1);
            //First switch
            network.addPathElement(new Switch(4, "Super Switch", 4));
            network.connect(4, 0, 3, 1);
            //first switch - second PC cable
            network.addPathElement(new Cable(5, 7, 3));
            network.connect(5, 0, 4, 1);
            //Test cable for the same path
            network.addPathElement(new Cable(27, 5, 5));
            network.connect(27, 0, 4, 3);
            //Second PC
            network.addPathElement(new PC(6, "ENIAC", 1));
            network.setActivePathElmentNetworkInterfaceIp(6, 0, "192.168.1.2");
            network.connect(6, 0, 5, 1);
            network.connect(6, 0, 27, 1);
            //first switch - firewall cable
            network.addPathElement(new Cable(7, 5, 5));
            network.connect(7, 0, 4, 2);
            //Firewall
            network.addPathElement(new Firewall(8, "Kashperovsky"));
            network.setActivePathElmentNetworkInterfaceIp(8, 0, "192.168.1.3");
            network.setActivePathElmentNetworkInterfaceIp(8, 1, "192.168.1.4");
            network.connect(8, 0, 7, 1);
            //firewall - router cable
            network.addPathElement(new Cable(9, 5, 5));
            network.connect(9, 0, 8, 1);
            //Router
            network.addPathElement(new Router(10, "dlink", 2));
            network.setActivePathElmentNetworkInterfaceIp(10, 0, "192.168.1.5");
            network.setActivePathElmentNetworkInterfaceIp(10, 1, "10.0.0.1");
            network.connect(10, 0, 9, 1);
            //Router - second switch cable
            network.addPathElement(new Cable(11, 5, 5));
            network.connect(11, 0, 10, 1);
            //Second switch
            network.addPathElement(new Switch(12, "Umbrella", 3));
            network.connect(12, 0, 11, 1);
            //Second switch - second PC cable
            network.addPathElement(new Cable(13, 5, 5));
            network.connect(13, 0, 12, 1);
            //Second PC
            network.addPathElement(new PC(14, "ENIGMA", 1));
            network.setActivePathElmentNetworkInterfaceIp(14, 0, "10.0.0.2");
            network.connect(14, 0, 13, 1);
            //Second switch - third PC cable
            network.addPathElement(new Cable(15, 5, 5));
            network.connect(15, 0, 12, 2);
            //Third PC
            network.addPathElement(new PC(16, "Made in China", 2));
            network.setActivePathElmentNetworkInterfaceIp(16, 0, "10.0.0.3");
            network.setActivePathElmentNetworkInterfaceIp(16, 1, "10.0.0.4");
            network.connect(16, 0, 15, 1);
            //Test cable for the same path
            network.addPathElement(new Cable(28, 5, 5));
            network.connect(28, 0, 0, 1);
            network.connect(16, 1, 28, 1);
            //AkimovsRouteProvider akimovsRouteProvider = new AkimovsRouteProvider();
            //LinkedList<ArrayList<PathElement>> findedPaths = akimovsRouteProvider.getRoutes(Protocol.TCP, "192.168.1.1", "10.0.0.3", 21, 21, network);
            //LinkedList<ArrayList<PathElement>> findedPaths2 = akimovsRouteProvider.getRoutes(Protocol.TCP, "192.168.1.1", "192.168.1.2", 21, 21, network);
            //System.out.println("Ta da!");
        } catch (Exception ex) {
            Logger.getLogger(NetworkModelTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
